﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using Bookkeeping.Core.Entities;
using Bookkeeping.Persistence.Repositories;
using Bookkeeping.Core.Persistence;
using NHibernate.Criterion;

namespace Bookkeeping.Persistence.Repositories
{
    public class TagRepository : Repository<Tag, int>, ITagRepository
    {
        public TagRepository() : base() { }
        public TagRepository(ISession session) : base(session) { }

        public IEnumerable<Tag> GetByPostId(int postId)
        {
            return Session.CreateQuery("select p.Tags from Post p where p.Id = :postId")
                .SetInt32("postId", postId)
                .List<Tag>();
        }
    }
}
